<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../../vue 2.6.10.js"></script>
</head>

<body>
    <div id="app">
        <!-- 直接修改基本类型数据 -->
        <button @click="hander">点击修改</button>
        <p>{{msg}}</p>
        <!-- 修改数组类型,通过数组方法修改原数组(push\pop\shift\unshift\splice\sort\reverse) -->
        <button @click="ArrAdd">数组添加</button>
        <ul>
            <li v-for="item,index of person">{{item}}</li>
        </ul>

        <button @click="ObjAdd">对象添加</button>
        <button @click="ObjDel">对象删除</button>
        <ul>
            <li v-for="value,key of obj" :key="item">{{key}} -- {{value}}</li>
        </ul>
    </div>
    <script>
        Vue.config.productionTip = false;
        
        const vm = new Vue({
            el: "#app",
            data() {
                return {
                    msg:"hello",
                    person:["A","B","C"],
                    obj:{
                        name:"zhangsan",
                        age:11
                    }
                }
            },
            methods: {
                hander(){
                    this.$data.msg="AAA"
                },
                ArrAdd(){
                    this.person.unshift("111")
                },
                ObjAdd(){
                    // this.$set(this.obj,"sex","男")
                    Vue.set(this.obj,"sex","男")
                },
                ObjDel(){
                    // this.$delete(this.obj,"age")
                    Vue.delete(this.obj,"sex")
                }
            },
        })
</script>
</body>

</html>